package com.heima.admin.job;


import com.heima.admin.service.impl.WemediaNewsAutoScanServiceImpl;
import com.heima.feigns.wemedia.WemediaFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@Slf4j
public class WeMediaNewsAutoScanJob {

    @Autowired
    WemediaFeign wemediaFeign;
    @Autowired
    WemediaNewsAutoScanServiceImpl autoScanService;

    @XxlJob("releaseTimeAudit")
    public ReturnT<String> autoScanJob(String param) throws Exception {
        log.info("***********************开始执行,autoScanJob任务*********************");
        System.out.println("***********************开始执行,autoScanJob任务*********************");
        List<Integer> release = wemediaFeign.findRelease();
        if(release!=null&&release.size()>0){
            release.stream().forEach(
                    x->autoScanService.autoScanByMediaNewsId(x)
            );
        }

        System.out.println("************************执行XxlJob任务结束*************************");
        log.info("************************执行XxlJob任务结束*************************");
        return ReturnT.SUCCESS;
    }


//    @RabbitListener(queues = "dlxqueue")
//    public void recv(String msg,Message message)throws Exception{
//        System.out.println("***********************开始执行,定时发布任务*********************");
//        System.out.println(msg);
////        System.out.println(message.toString());
//        if(StringUtils.isNotBlank(msg)){
//            Integer id = Integer.valueOf(msg);
//            autoScanService.autoScanByMediaNewsId(id);
//        }
//        System.out.println("************************执行定时发布任务结束*************************");
//
//    }

}